package com.jps;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.Input;
import org.springframework.cloud.stream.annotation.Output;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.cloud.stream.messaging.Sink;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.SubscribableChannel;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * source 发送消息通道
 * sink 接收消息通道
 */
//@EnableBinding(value = {HelloRocketmqApplication.TestTopic.class})
@SpringBootApplication
public class HelloRocketmqApplication {

	public static void main(String[] args) {
		SpringApplication.run(HelloRocketmqApplication.class, args);
	}

	/*@RestController
	static class TestController {

		@Autowired
		private TestTopic testTopic;

		*//**
		 * 消息生产接口
		 * @param msg
		 * @return
		 *//*
		@GetMapping("/send/{msg}")
		public String messageWithMQ(@PathVariable String msg) {
			testTopic.output().send(MessageBuilder.withPayload(msg).build());
			return "ok";
		}

	}

	*//**
	 * 消息消费逻辑
	 *//*
	@Slf4j
	@Component
	static class TestListener {

		@StreamListener(TestTopic.INPUT)
		public void receive(String payload) {
			System.out.println(payload);
		}

	}


	interface TestTopic {

		String OUTPUT = "myOutput";
		String INPUT = "myInput";

		@Output(OUTPUT)
		MessageChannel output();

		@Input(INPUT)
		SubscribableChannel input();

	}*/
}
